package org.example.autosuggest;

public class SuggestionItem implements Comparable<SuggestionItem>{
    private String token;
    private String completion;

    private SuggestionKind kind;

    private SuggestionItem(String token, String completion, SuggestionKind kind) {
        this.token = token;
        this.completion = completion;
        this.kind = kind;
    }

    public static SuggestionItem symbol(String token, String completion) {
        return new SuggestionItem(token, completion, SuggestionKind.SYMBOL);
    }

    public String getToken() {
        return token;
    }

    public String getCompletion() {
        return completion;
    }

    public SuggestionKind getKind() {
        return kind;
    }

    @Override
    public int compareTo(SuggestionItem o) {
        if (null == o) {
            return 1;
        }
        return token.compareTo(o.token);
    }

    @Override
    public String toString() {
        return "SuggestionItem{" +
                "token='" + token + '\'' +
                ", completion='" + completion + '\'' +
                ", kind=" + kind +
                '}';
    }
}
